package top.kaoshanji.s1ch08b;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author kaoshanji
 * ^_^
 * create time 2025/4/29 17:09
 */
@Controller
public class MainController {

    /**
     * 代码清单-s1ch08b-167页a：获取请求参数值
     * @param name
     * @param color
     * @param model
     * @return
     */
    @RequestMapping("/home")
    public String home(@RequestParam(required = false, defaultValue = "aa") String name,
                       @RequestParam(required = false, defaultValue = "red") String color,
                       Model model) {
        model.addAttribute("username", name);
        model.addAttribute("color", color);
        return "home.html";
    }

}
